home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 8
/
FM Towns Free Software Collection 8.iso
/
t_os
/
artemis
/
artsrc1
/
plt16asm.asm
< prev
next >
Wrap
Assembly Source File
|
1994-06-01
|
47KB
|
890 lines
MetaWare High C Compiler 1.7 22-Dec-92 09:16:10 plt16.c Page 1
Copyright (C) 1983-90 MetaWare Incorporated. Serial 1-999999.
Target: Intel 80386/486
Scanner C_lexicon(18-Jan-90 18:27:04)
Parser C_phrase_structure(07-Nov-90 09:25:08)
=====> Profile j:\c\inc/hc.pro included in this compilation.
MetaWare High C Compiler 1.7 22-Dec-92 09:16:10 plt16.c Page 2
Addr Object Source Program and Assembly Listing
extrn _egbwork,scrmode,debugmsg,EGB_getPalette
extrn EGB_palette,sprintf,msgout,calloc
plt16 segment 'CODE'
0000 mod4 0
;/*
; ARTemis (Graphic Editor for FM-TOWNS)
; (c) MATSUUCHI Ryosuke 1992
; plt16.c
; このモジュールは、16色モードにおいてパレットどうしの混色や
; 近似パレット検索を行うときの処理のためのものです。
;*/
;#include <stdio.h>
;#include <malloc.h>
;#include <egb.h>
;#include "ge.h"
;#include "plt.h"
;// (local) 指定したパレット番号のパレットを得る
;//-----------------------------------------------------------------------
;static _GRB _getplt(int plt)
0000 .L0000:
_getplt proc near
0000 55 push ebp
0001 8b ec mov ebp,esp
0003 81 ec 00000084 sub esp,132
0009 57 push edi
;{
000a 8b 7d 08 mov edi,8[ebp]
; unsigned char pal_[4+8*16];
; EGB_getPalette(1,(char *)pal_);
000d 8d 85 ffffff7c lea eax,-132[ebp]
0013 50 push eax
0014 6a 01 push 1
0016 e8 --------e call EGB_getPalette
; return (int)((pal_[4+8*plt+4+2]>>4)&15)*256 +
001b 0f b6 44 fd 86 movzbl eax,-122[ebp+edi*8]
0020 c1 f8 04 sar eax,4
0023 25 0000000f and eax,15
0028 c1 e0 08 shl eax,8
002b 0f b6 54 fd 85 movzbl edx,-123[ebp+edi*8]
0030 c1 fa 04 sar edx,4
0033 81 e2 0000000f and edx,15
0039 c1 e2 04 shl edx,4
003c 03 d0 add edx,eax
003e 0f b6 44 fd 84 movzbl eax,-124[ebp+edi*8]
0043 c1 f8 04 sar eax,4
0046 25 0000000f and eax,15
004b 03 c2 add eax,edx
004d 83 c4 08 add esp,8
; (int)((pal_[4+8*plt+4+1]>>4)&15)* 16 +
; (int)((pal_[4+8*plt+4 ]>>4)&15);
;}
0050 5f pop edi
0051 c9 leave
0052 c3 rets
_getplt endp
0053 90 mod4 0
;// (local) 指定したパレット番号のパレットを設定する
MetaWare High C Compiler 1.7 22-Dec-92 09:16:10 plt16.c Page 3
Addr Object Source Program and Assembly Listing
;//-----------------------------------------------------------------------
;static void _setplt(int plt, _GRB grb)
0054 .L0054:
_setplt proc near
0054 55 push ebp
0055 8b ec mov ebp,esp
0057 81 ec 00000084 sub esp,132
005d 57 push edi
;{
005e 8b 7d 0c mov edi,12[ebp]
; char pal_[4+8*16];
; DWORD(pal_ + 0) = 1;
0061 c7 85 ffffff7c 00000001 mov dword ptr -132[ebp],1
; DWORD(pal_ + 4) = plt;
006b 8b 45 08 mov eax,8[ebp]
006e 89 45 80 mov -128[ebp],eax
; BYTE (pal_ + 8) = (grb&15) << 4;
0071 8b c7 mov eax,edi
0073 25 0000000f and eax,15
0078 c0 e0 04 shl al,4
007b 88 45 84 mov -124[ebp],al
; BYTE (pal_ + 9) = ((grb>>4)&15)<<4;
007e 8b c7 mov eax,edi
0080 c1 f8 04 sar eax,4
0083 25 0000000f and eax,15
0088 c0 e0 04 shl al,4
008b 88 45 85 mov -123[ebp],al
; BYTE (pal_ +10) = ((grb>>8)&15)<<4;
008e 8b c7 mov eax,edi
0090 c1 f8 08 sar eax,8
0093 25 0000000f and eax,15
0098 c0 e0 04 shl al,4
009b 88 45 86 mov -122[ebp],al
; BYTE (pal_ +11) = 0;
009e 2b c0 sub eax,eax
00a0 88 45 87 mov -121[ebp],al
; EGB_palette(_egbwork,0,pal_);
00a3 8d 95 ffffff7c lea edx,-132[ebp]
00a9 52 push edx
00aa 50 push eax
00ab 68 00000000e push offset _egbwork
00b0 e8 --------e call EGB_palette
00b5 83 c4 0c add esp,12
;}
00b8 5f pop edi
00b9 c9 leave
00ba c3 rets
_setplt endp
00bb 90 mod4 0
;// (local) _GRB カラーどうしの「相違度(difference)」を計算する
;//-----------------------------------------------------------------------
;static int _coldiff(_GRB grb1, _GRB grb2)
00bc .L00bc:
_coldiff proc near
00bc 55 push ebp
00bd 8b ec mov ebp,esp
00bf 56 push esi
MetaWare High C Compiler 1.7 22-Dec-92 09:16:10 plt16.c Page 4
Addr Object Source Program and Assembly Listing
00c0 57 push edi
;{
00c1 8b 7d 08 mov edi,8[ebp]
; int t,r;
; r = 0;
00c4 2b c9 sub ecx,ecx
; t = (int)((grb1>>8)&15)-(int)((grb2>>8)&15);
00c6 8b 45 0c mov eax,12[ebp]
00c9 c1 f8 08 sar eax,8
00cc 25 0000000f and eax,15
00d1 8b f7 mov esi,edi
00d3 c1 fe 08 sar esi,8
00d6 81 e6 0000000f and esi,15
00dc 2b f0 sub esi,eax
; r += t*t;
00de 8b c6 mov eax,esi
00e0 f7 e0 mul eax
00e2 03 c8 add ecx,eax
; t = (int)((grb1>>4)&15)-(int)((grb2>>4)&15);
00e4 8b 45 0c mov eax,12[ebp]
00e7 c1 f8 04 sar eax,4
00ea 25 0000000f and eax,15
00ef 8b f7 mov esi,edi
00f1 c1 fe 04 sar esi,4
00f4 81 e6 0000000f and esi,15
00fa 2b f0 sub esi,eax
; r += t*t;
00fc 8b c6 mov eax,esi
00fe f7 e0 mul eax
0100 03 c8 add ecx,eax
; t = (int)(grb1&15)-(int)(grb2&15);
0102 8b 45 0c mov eax,12[ebp]
0105 25 0000000f and eax,15
010a 8b f7 mov esi,edi
010c 81 e6 0000000f and esi,15
0112 2b f0 sub esi,eax
; r += t*t;
0114 8b c6 mov eax,esi
0116 f7 e0 mul eax
0118 03 c8 add ecx,eax
; return r;
011a 8b c1 mov eax,ecx
;}
011c 5f pop edi
011d 5e pop esi
011e c9 leave
011f c3 rets
_coldiff endp
0120 mod4 0
;// (local) 近似パレットリストのための型定義・変数定義
;//-----------------------------------------------------------------------
;typedef struct _nearplt_e { // 近似パレットリストの1要素(NEARPLTの補助)
; struct _nearplt_e *next;
; bool used;
; char plt;
; int dist;
;} NEARPLTe;
MetaWare High C Compiler 1.7 22-Dec-92 09:16:10 plt16.c Page 5
Addr Object Source Program and Assembly Listing
;typedef struct { // ある _GRB カラーに対する近似パレットリスト
; NEARPLTe *neartop;
; NEARPLTe near[16];
;} NEARPLT;
;static NEARPLT *nearplt; // 全 _GRB カラーに対する近似パレットリスト
;static _GRB pltgrb[16]; // 各パレットの現在の設定状態
;// (local) 近似パレットリストへの要素の挿入
;//-----------------------------------------------------------------------
;static void NEARPLT_ins(_GRB grb, int plt)
0120 .L0120:
NEARPLT_ins proc near
0120 55 push ebp
0121 8b ec mov ebp,esp
0123 83 ec 10 sub esp,16
0126 53 push ebx
0127 56 push esi
0128 57 push edi
;// [_GRBカラー grb に対する近似パレットリストに、plt 番のパレットを挿入する]
;// この関数は、_GRBカラー grb に対する近似パレットリストに plt 番の
;// パレットがまだ登録されていない状態で呼ばなくてはいけない。
;{
; NEARPLT *nplt;
; int dist;
; nplt = nearplt + grb;
0129 8b 45 08 mov eax,8[ebp]
012c 8d 04 85 00000000 lea eax,[eax*4]
0133 8d 14 80 lea edx,[eax+eax*4]
0136 8d 14 d0 lea edx,[eax+edx*8]
0139 03 15 00000000r add edx,@plt16
013f 89 55 fc mov -4[ebp],edx
; dist = _coldiff(grb, pltgrb[plt]);
0142 8b 45 0c mov eax,12[ebp]
0145 ff 34 85 00000004r push dword ptr @plt16+4[eax*4]
014c ff 75 08 push dword ptr 8[ebp]
014f 8b da mov ebx,edx
0151 e8 ffffff66 call 00bc
0156 89 45 f8 mov -8[ebp],eax
0159 83 c4 08 add esp,8
; if (nplt->neartop == NULL) {
015c 83 3b 00 cmp dword ptr [ebx],0
015f 75 1d jne 017e
; NEARPLTe *p;
; p = &(nplt->near[0]);
0161 8d 7b 04 lea edi,4[ebx]
; p->next = NULL;
0164 c7 07 00000000 mov dword ptr [edi],0
; p->used = YES;
016a c6 47 04 01 mov byte ptr 4[edi],1
; p->plt = plt;
016e 8a 55 0c mov dl,12[ebp]
0171 88 57 05 mov 5[edi],dl
; p->dist = dist;
0174 89 47 06 mov 6[edi],eax
; nplt->neartop = p;
0177 89 3b mov [ebx],edi
0179 e9 000000c7 jmp 0245
; } else {
MetaWare High C Compiler 1.7 22-Dec-92 09:16:10 plt16.c Page 6
Addr Object Source Program and Assembly Listing
; NEARPLTe *p1,*p2,*p;
; bool done;
; int i;
; done = NO;
017e .L017e:
017e 2b c0 sub eax,eax
0180 88 45 f3 mov -13[ebp],al
; for (p1=nplt->neartop,p2=NULL; p1!=NULL; p2=p1,p1=p1->next) {
0183 8b 55 fc mov edx,-4[ebp]
0186 8b 3a mov edi,[edx]
0188 89 45 f4 mov -12[ebp],eax
018b .L018b:
018b 23 ff and edi,edi
018d 74 64 je 01f3
; if (dist < p1->dist) {
018f 8b 45 f8 mov eax,-8[ebp]
0192 3b 47 06 cmp eax,6[edi]
0195 7d 55 jnl 01ec
; done = YES;
0197 c6 45 f3 01 mov byte ptr -13[ebp],1
; for (i=0; i<16; i++)
019b 2b db sub ebx,ebx
019d .L019d:
019d 83 fb 10 cmp ebx,16
01a0 7d 12 jnl 01b4
; if (! nplt->near[i].used) break;
01a2 8d 04 9b lea eax,[ebx+ebx*4]
01a5 03 c0 add eax,eax
01a7 8b 55 fc mov edx,-4[ebp]
01aa 80 7c 02 08 00 cmp byte ptr 8[edx+eax],0
01af 74 03 je 01b4
01b1 43 inc ebx
01b2 eb e9 jmp 019d
; if (i==16)
01b4 .L01b4:
01b4 83 fb 10 cmp ebx,16
01b7 0f 84 00000088 je 0245
; return;
; p = &(nplt->near[i]);
01bd 8d 04 9b lea eax,[ebx+ebx*4]
01c0 03 c0 add eax,eax
01c2 8b 55 fc mov edx,-4[ebp]
01c5 8d 74 02 04 lea esi,4[edx+eax]
; p->used = YES;
01c9 c6 46 04 01 mov byte ptr 4[esi],1
; p->next = p1;
01cd 89 3e mov [esi],edi
; p->plt = plt;
01cf 8a 45 0c mov al,12[ebp]
01d2 88 46 05 mov 5[esi],al
; p->dist = dist;
01d5 8b 45 f8 mov eax,-8[ebp]
01d8 89 46 06 mov 6[esi],eax
; if (p2 == NULL)
01db 83 7d f4 00 cmp dword ptr -12[ebp],0
01df 75 04 jne 01e5
; nplt->neartop = p;
MetaWare High C Compiler 1.7 22-Dec-92 09:16:10 plt16.c Page 7
Addr Object Source Program and Assembly Listing
01e1 89 32 mov [edx],esi
01e3 eb 0e jmp 01f3
; else
; p2->next = p;
01e5 .L01e5:
01e5 8b 45 f4 mov eax,-12[ebp]
01e8 89 30 mov [eax],esi
; break;
01ea eb 07 jmp 01f3
01ec .L01ec:
01ec 89 7d f4 mov -12[ebp],edi
01ef 8b 3f mov edi,[edi]
01f1 eb 98 jmp 018b
; }
; }
; if (!done) {
01f3 .L01f3:
01f3 80 7d f3 00 cmp byte ptr -13[ebp],0
01f7 75 4c jne 0245
; for (i=0; i<16; i++)
01f9 2b db sub ebx,ebx
01fb .L01fb:
01fb 83 fb 10 cmp ebx,16
01fe 7d 12 jnl 0212
; if (! nplt->near[i].used) break;
0200 8d 04 9b lea eax,[ebx+ebx*4]
0203 03 c0 add eax,eax
0205 8b 55 fc mov edx,-4[ebp]
0208 80 7c 02 08 00 cmp byte ptr 8[edx+eax],0
020d 74 03 je 0212
020f 43 inc ebx
0210 eb e9 jmp 01fb
; if (i==16)
0212 .L0212:
0212 83 fb 10 cmp ebx,16
0215 74 2e je 0245
; return;
; p = &(nplt->near[i]);
0217 8d 04 9b lea eax,[ebx+ebx*4]
021a 03 c0 add eax,eax
021c 8b 55 fc mov edx,-4[ebp]
021f 8d 74 02 04 lea esi,4[edx+eax]
; p->used = YES;
0223 c6 46 04 01 mov byte ptr 4[esi],1
; p->next = NULL;
0227 2b c0 sub eax,eax
0229 89 06 mov [esi],eax
; p->plt = plt;
022b 8a 4d 0c mov cl,12[ebp]
022e 88 4e 05 mov 5[esi],cl
; p->dist = dist;
0231 8b 4d f8 mov ecx,-8[ebp]
0234 89 4e 06 mov 6[esi],ecx
; if (p2 == NULL)
0237 3b 45 f4 cmp eax,-12[ebp]
023a 75 04 jne 0240
; nplt->neartop = p;
MetaWare High C Compiler 1.7 22-Dec-92 09:16:10 plt16.c Page 8
Addr Object Source Program and Assembly Listing
023c 89 32 mov [edx],esi
023e eb 05 jmp 0245
; else
; p2->next = p;
0240 .L0240:
0240 8b 45 f4 mov eax,-12[ebp]
0243 89 30 mov [eax],esi
; }
; }
;}
0245 .L0245:
0245 5f pop edi
0246 5e pop esi
0247 5b pop ebx
0248 c9 leave
0249 c3 rets
NEARPLT_ins endp
024a 8bc0 mod4 0
;// (local) 近似パレットリストの要素の削除
;//-----------------------------------------------------------------------
;static void NEARPLT_del(int grb, int plt)
024c .L024c:
NEARPLT_del proc near
024c 55 push ebp
024d 8b ec mov ebp,esp
024f 56 push esi
0250 57 push edi
;// [_GRBカラー grb に対する近似パレットリストの中から、
;// plt番のパレットの要素を削除する]
;// この関数は、リスト中に見つかった plt 番のパレット要素をすべて
;// 削除する。また、リスト中に plt 番のパレット要素が存在しなくても
;// 問題はない。
;{
; NEARPLT *nplt;
; nplt = nearplt + grb;
0251 8b 45 08 mov eax,8[ebp]
0254 8d 04 85 00000000 lea eax,[eax*4]
025b 8d 14 80 lea edx,[eax+eax*4]
025e 8d 14 d0 lea edx,[eax+edx*8]
0261 8b fa mov edi,edx
0263 03 3d 00000000r add edi,@plt16
; NEARPLTe *p1,*p2;
; for (p1=nplt->neartop,p2=NULL; p1!=NULL; p2=p1,p1=p1->next) {
0269 8b 37 mov esi,[edi]
026b 2b c9 sub ecx,ecx
026d .L026d:
026d 23 f6 and esi,esi
026f 74 21 je 0292
; if (p1->plt == plt) {
0271 0f b6 46 05 movzbl eax,5[esi]
0275 3b 45 0c cmp eax,12[ebp]
0278 75 12 jne 028c
; if (p2==NULL)
027a 23 c9 and ecx,ecx
027c 75 06 jne 0284
; nplt->neartop = p1->next;
027e 8b 06 mov eax,[esi]
MetaWare High C Compiler 1.7 22-Dec-92 09:16:10 plt16.c Page 9
Addr Object Source Program and Assembly Listing
0280 89 07 mov [edi],eax
0282 eb 04 jmp 0288
; else
; p2->next = p1->next;
0284 .L0284:
0284 8b 06 mov eax,[esi]
0286 89 01 mov [ecx],eax
; p1->used = NO;
0288 .L0288:
0288 c6 46 04 00 mov byte ptr 4[esi],0
028c .L028c:
028c 8b ce mov ecx,esi
028e 8b 36 mov esi,[esi]
0290 eb db jmp 026d
; }
; }
;}
0292 .L0292:
0292 5f pop edi
0293 5e pop esi
0294 c9 leave
0295 c3 rets
NEARPLT_del endp
0296 8bc0 mod4 0
;// (global) _GRB カラー 000 に対する近似パレットリストのダンプ出力
;// (デバッグ用関数)
;//-----------------------------------------------------------------------
;void __dumpNEARPLT0()
0298 .L0298:
public __dumpNEARPLT0
__dumpNEARPLT0 proc near
0298 56 push esi
0299 57 push edi
;{
; if (scrmode == 10)
029a 83 3d 00000000e 0a cmp dword ptr scrmode,10
02a1 74 6e je 0311
; return;
; int tc = 0*256+0*16+0;
02a3 2b ff sub edi,edi
; sprintf(debugmsg,"nearplt[%03x] dump:",tc);
02a5 57 push edi
02a6 68 00000000r push offset _mwLITERALS
02ab 68 00000000e push offset debugmsg
02b0 e8 --------e call sprintf
; msgout(debugmsg);
02b5 68 00000000e push offset debugmsg
02ba e8 --------e call msgout
; NEARPLTe *p;
; p = (nearplt+tc)->neartop;
02bf 8d 04 bd 00000000 lea eax,[edi*4]
02c6 8d 14 80 lea edx,[eax+eax*4]
02c9 8d 14 d0 lea edx,[eax+edx*8]
02cc a1 00000000r mov eax,@plt16
02d1 8b 34 10 mov esi,[eax+edx]
02d4 83 c4 10 add esp,16
; for ( ; p!=NULL; p=p->next) {
MetaWare High C Compiler 1.7 22-Dec-92 09:16:10 plt16.c Page 10
Addr Object Source Program and Assembly Listing
02d7 .L02d7:
02d7 23 f6 and esi,esi
02d9 74 36 je 0311
; sprintf(debugmsg, " %1x[%03x] d%4d", p->plt, plt16_get(p->plt), p->dist);
02db ff 76 06 push dword ptr 6[esi]
02de 0f b6 46 05 movzbl eax,5[esi]
02e2 50 push eax
02e3 e8 000000e8 call 03d0
02e8 83 c4 04 add esp,4
02eb 50 push eax
02ec 0f b6 46 05 movzbl eax,5[esi]
02f0 50 push eax
02f1 68 00000014r push offset _mwLITERALS+20
02f6 68 00000000e push offset debugmsg
02fb e8 --------e call sprintf
; msgout(debugmsg);
0300 68 00000000e push offset debugmsg
0305 e8 --------e call msgout
030a 8b 36 mov esi,[esi]
030c 83 c4 18 add esp,24
030f eb c6 jmp 02d7
; }
;}
0311 .L0311:
0311 5f pop edi
0312 5e pop esi
0313 c3 rets
__dumpNEARPLT0 endp
0314 mod4 0
;// (global) 近似パレットリストおよびこのモジュールの初期化
;//-----------------------------------------------------------------------
;int plt16_init()
0314 .L0314:
public plt16_init
plt16_init proc near
0314 56 push esi
0315 57 push edi
;{
; int i,j;
; nearplt = calloc(sizeof(NEARPLT), 4096);
0316 68 00001000 push 4096
031b 68 000000a4 push 164
0320 e8 --------e call calloc
0325 a3 00000000r mov @plt16,eax
032a 83 c4 08 add esp,8
; if (nearplt == NULL)
032d 23 c0 and eax,eax
032f 75 07 jne 0338
; return -1;
0331 b8 ffffffff mov eax,-1
0336 eb 42 jmp 037a
; for (i=0; i<16; i++)
0338 .L0338:
0338 2b ff sub edi,edi
033a .L033a:
033a 83 ff 10 cmp edi,16
033d 7d 13 jnl 0352
MetaWare High C Compiler 1.7 22-Dec-92 09:16:10 plt16.c Page 11
Addr Object Source Program and Assembly Listing
; pltgrb[i] = _getplt(i);
033f 57 push edi
0340 e8 fffffcbb call 0000
0345 89 04 bd 00000004r mov @plt16+4[edi*4],eax
034c 47 inc edi
034d 83 c4 04 add esp,4
0350 eb e8 jmp 033a
; for (i=0; i<4096; i++)
0352 .L0352:
0352 2b ff sub edi,edi
0354 .L0354:
0354 81 ff 00001000 cmp edi,4096
035a 7d 17 jnl 0373
; for (j=0; j<16; j++)
035c 2b f6 sub esi,esi
035e .L035e:
035e 83 fe 10 cmp esi,16
0361 7d 0d jnl 0370
; NEARPLT_ins(i,j);
0363 56 push esi
0364 57 push edi
0365 e8 fffffdb6 call 0120
036a 46 inc esi
036b 83 c4 08 add esp,8
036e eb ee jmp 035e
0370 .L0370:
0370 47 inc edi
0371 eb e1 jmp 0354
; __dumpNEARPLT0();
0373 .L0373:
0373 e8 ffffff20 call 0298
; return 0;
0378 2b c0 sub eax,eax
;}
037a .L037a:
037a 5f pop edi
037b 5e pop esi
037c c3 rets
plt16_init endp
037d 668bc0 mod4 0
;// (global) 指定したパレット番号に対するパレットの設定
;//-----------------------------------------------------------------------
;void plt16_set(int plt, _GRB grb)
0380 .L0380:
public plt16_set
plt16_set proc near
0380 55 push ebp
0381 8b ec mov ebp,esp
0383 53 push ebx
0384 56 push esi
0385 57 push edi
;{
0386 8b 7d 08 mov edi,8[ebp]
0389 8b 75 0c mov esi,12[ebp]
; int i;
; for (i=0; i<4096; i++)
038c 2b db sub ebx,ebx
MetaWare High C Compiler 1.7 22-Dec-92 09:16:10 plt16.c Page 12
Addr Object Source Program and Assembly Listing
038e .L038e:
038e 81 fb 00001000 cmp ebx,4096
0394 7d 0d jnl 03a3
; NEARPLT_del(i,plt);
0396 57 push edi
0397 53 push ebx
0398 e8 fffffeaf call 024c
039d 43 inc ebx
039e 83 c4 08 add esp,8
03a1 eb eb jmp 038e
; _setplt(plt, grb);
03a3 .L03a3:
03a3 56 push esi
03a4 57 push edi
03a5 e8 fffffcaa call 0054
; pltgrb[plt] = grb;
03aa 89 34 bd 00000004r mov @plt16+4[edi*4],esi
; for (i=0; i<4096; i++)
03b1 2b db sub ebx,ebx
03b3 .L03b3:
03b3 83 c4 08 add esp,8
03b6 81 fb 00001000 cmp ebx,4096
03bc 7d 0a jnl 03c8
; NEARPLT_ins(i,plt);
03be 57 push edi
03bf 53 push ebx
03c0 e8 fffffd5b call 0120
03c5 43 inc ebx
03c6 eb eb jmp 03b3
;}
03c8 .L03c8:
03c8 5f pop edi
03c9 5e pop esi
03ca 5b pop ebx
03cb c9 leave
03cc c3 rets
plt16_set endp
03cd 668bc0 mod4 0
;// (global) 指定したパレット番号に対するパレット内容を得る
;//-----------------------------------------------------------------------
;_GRB plt16_get(int plt)
03d0 .L03d0:
public plt16_get
plt16_get proc near
;{
; return pltgrb[plt];
03d0 8b 44 24 04 mov eax,4[esp]
03d4 8b 04 85 00000004r mov eax,@plt16+4[eax*4]
;}
03db c3 rets
plt16_get endp
03dc mod4 0
;// (global) 指定した _GRB カラーの近似パレットを得る
;//-----------------------------------------------------------------------
;int plt16_getnear(_GRB grb, int source_plt, int object_plt)
03dc .L03dc:
public plt16_getnear
MetaWare High C Compiler 1.7 22-Dec-92 09:16:10 plt16.c Page 13
Addr Object Source Program and Assembly Listing
plt16_getnear proc near
03dc 55 push ebp
03dd 8b ec mov ebp,esp
03df 50 push eax
03e0 53 push ebx
03e1 56 push esi
03e2 57 push edi
;// 指定されたRGBカラーに最も近いパレットを返す
;{
03e3 8b 7d 10 mov edi,16[ebp]
; NEARPLT *nplt;
; nplt = nearplt + grb;
03e6 8b 45 08 mov eax,8[ebp]
03e9 8d 04 85 00000000 lea eax,[eax*4]
03f0 8d 14 80 lea edx,[eax+eax*4]
03f3 8d 14 d0 lea edx,[eax+edx*8]
03f6 03 15 00000000r add edx,@plt16
03fc 89 55 fc mov -4[ebp],edx
; NEARPLTe *p;
; p = nplt->neartop;
03ff 8b 32 mov esi,[edx]
; if (p->plt != source_plt)
0401 0f b6 46 05 movzbl eax,5[esi]
0405 3b 45 0c cmp eax,12[ebp]
0408 75 5e jne 0468
; return p->plt;
; else { // 「一番近い色」がもとの色と同じ色の場合
; int distmax = (nearplt+pltgrb[p->plt])->near[object_plt].dist;
040a 0f b6 46 05 movzbl eax,5[esi]
040e 8b 04 85 00000004r mov eax,@plt16+4[eax*4]
0415 8d 04 85 00000000 lea eax,[eax*4]
041c 8d 14 80 lea edx,[eax+eax*4]
041f 8d 14 d0 lea edx,[eax+edx*8]
0422 8d 04 bf lea eax,[edi+edi*4]
0425 03 c0 add eax,eax
0427 03 c2 add eax,edx
0429 8b 15 00000000r mov edx,@plt16
042f 8b 5c 02 0a mov ebx,10[edx+eax]
; // distmax = _min(distmax, _coldiff(pltgrb[source_plt], pltgrb[object_plt]));
; for (p=p->next; p!=NULL; p=p->next) {
0433 .L0433:
0433 8b 36 mov esi,[esi]
0435 23 f6 and esi,esi
0437 74 2d je 0466
; if ((nearplt+pltgrb[p->plt])->near[object_plt].dist <= distmax)
0439 0f b6 46 05 movzbl eax,5[esi]
043d 8b 14 85 00000004r mov edx,@plt16+4[eax*4]
0444 8d 14 95 00000000 lea edx,[edx*4]
044b 8d 0c 92 lea ecx,[edx+edx*4]
044e 8d 0c ca lea ecx,[edx+ecx*8]
0451 8d 14 bf lea edx,[edi+edi*4]
0454 03 d2 add edx,edx
0456 03 d1 add edx,ecx
0458 8b 0d 00000000r mov ecx,@plt16
045e 3b 5c 11 0a cmp ebx,10[ecx+edx]
0462 7d 04 jnl 0468
; return p->plt;
MetaWare High C Compiler 1.7 22-Dec-92 09:16:10 plt16.c Page 14
Addr Object Source Program and Assembly Listing
0464 eb cd jmp 0433
; }
; return object_plt;
0466 .L0466:
0466 8b c7 mov eax,edi
; }
;}
0468 .L0468:
0468 5f pop edi
0469 5e pop esi
046a 5b pop ebx
046b c9 leave
046c c3 rets
plt16_getnear endp
046d 668bc0 mod4 0
;// (global) 指定した2つの _GRB カラーを混ぜ合わせる
;//-----------------------------------------------------------------------
;_GRB plt16_gray(_GRB grb1, _GRB grb2, int gray)
0470 .L0470:
public plt16_gray
plt16_gray proc near
0470 55 push ebp
0471 8b ec mov ebp,esp
0473 83 ec 24 sub esp,36
0476 53 push ebx
0477 56 push esi
0478 57 push edi
;// gray : 0..256(grb2の「強さ」)
;{
0479 8b 7d 08 mov edi,8[ebp]
047c 8b 75 10 mov esi,16[ebp]
; if (gray == 0)
047f 23 f6 and esi,esi
0481 75 07 jne 048a
; return grb1;
0483 8b c7 mov eax,edi
0485 e9 000000e2 jmp 056c
; else if (gray == 256)
048a .L048a:
048a 81 fe 00000100 cmp esi,256
0490 75 08 jne 049a
; return grb2;
0492 8b 45 0c mov eax,12[ebp]
0495 e9 000000d2 jmp 056c
; else {
; gray = _min(256,_max(gray,0));
049a .L049a:
049a 2b c0 sub eax,eax
049c 3b c6 cmp eax,esi
049e 7c 01 jl 04a1
04a0 96 xchg eax,esi
04a1 .L04a1:
04a1 b8 00000100 mov eax,256
04a6 3b f0 cmp esi,eax
04a8 7c 02 jl 04ac
04aa 8b f0 mov esi,eax
; int gg,r1,r2,g1,g2,b1,b2,r,g,b;
MetaWare High C Compiler 1.7 22-Dec-92 09:16:10 plt16.c Page 15
Addr Object Source Program and Assembly Listing
; gg = 256-gray;
04ac .L04ac:
04ac 8b d8 mov ebx,eax
04ae 2b de sub ebx,esi
; g1 = (grb1>>8)&15;
04b0 8b d7 mov edx,edi
04b2 c1 fa 08 sar edx,8
04b5 81 e2 0000000f and edx,15
04bb 89 55 f4 mov -12[ebp],edx
; r1 = (grb1>>4)&15;
04be 8b c7 mov eax,edi
04c0 c1 f8 04 sar eax,4
04c3 25 0000000f and eax,15
04c8 89 45 fc mov -4[ebp],eax
; b1 = grb1 & 15;
04cb 8b cf mov ecx,edi
04cd 81 e1 0000000f and ecx,15
04d3 89 4d ec mov -20[ebp],ecx
; g2 = (grb2>>8)&15;
04d6 8b 45 0c mov eax,12[ebp]
04d9 c1 f8 08 sar eax,8
04dc 25 0000000f and eax,15
04e1 89 45 f0 mov -16[ebp],eax
; r2 = (grb2>>4)&15;
04e4 8b 45 0c mov eax,12[ebp]
04e7 c1 f8 04 sar eax,4
04ea 25 0000000f and eax,15
04ef 89 45 f8 mov -8[ebp],eax
; b2 = grb2 & 15;
04f2 8b 45 0c mov eax,12[ebp]
04f5 25 0000000f and eax,15
04fa 89 45 e8 mov -24[ebp],eax
; g = (gg*g1 + gray*g2 + 128) / 256;
04fd 0f af d3 imul edx,ebx
0500 8b c6 mov eax,esi
0502 0f af 45 f0 imul eax,-16[ebp]
0506 03 c2 add eax,edx
0508 05 00000080 add eax,128
050d 99 cwd
050e b9 00000100 mov ecx,256
0513 f7 f9 idiv ecx
0515 89 45 e0 mov -32[ebp],eax
; r = (gg*r1 + gray*r2 + 128) / 256;
0518 8b d3 mov edx,ebx
051a 0f af 55 fc imul edx,-4[ebp]
051e 8b ce mov ecx,esi
0520 0f af 4d f8 imul ecx,-8[ebp]
0524 03 ca add ecx,edx
0526 81 c1 00000080 add ecx,128
052c 91 xchg eax,ecx
052d 99 cwd
052e b9 00000100 mov ecx,256
0533 f7 f9 idiv ecx
0535 89 45 e4 mov -28[ebp],eax
; b = (gg*b1 + gray*b2 + 128) / 256;
0538 8b d3 mov edx,ebx
053a 0f af 55 ec imul edx,-20[ebp]
MetaWare High C Compiler 1.7 22-Dec-92 09:16:10 plt16.c Page 16
Addr Object Source Program and Assembly Listing
053e 8b ce mov ecx,esi
0540 0f af 4d e8 imul ecx,-24[ebp]
0544 03 ca add ecx,edx
0546 81 c1 00000080 add ecx,128
054c 91 xchg eax,ecx
054d 99 cwd
054e b9 00000100 mov ecx,256
0553 f7 f9 idiv ecx
0555 89 45 dc mov -36[ebp],eax
; return (g<<8)|(r<<4)|b;
0558 8b 55 e0 mov edx,-32[ebp]
055b c1 e2 08 shl edx,8
055e 8b 45 e4 mov eax,-28[ebp]
0561 c1 e0 04 shl eax,4
0564 0b c2 or eax,edx
0566 8b 55 dc mov edx,-36[ebp]
0569 0b d0 or edx,eax
056b 92 xchg eax,edx
; }
;}
056c .L056c:
056c 5f pop edi
056d 5e pop esi
056e 5b pop ebx
056f c9 leave
0570 c3 rets
plt16_gray endp
plt16 ends
_mwLITERALS segment public 'DATA'
0000 6e656172706c745b25303378 db 'nearplt[%03x'
000c 5d2064756d703a db '] dump:'
0013 00 db 0
0014 202531785b253033785d2064 db ' %1x[%03x] d'
0020 253464 db '%4d'
0023 00 db 0
0024 _mwLITERALS ends
;/* end of plt16.c */
No user errors No warnings
End of processing, 22-Dec-92 09:16:23 plt16.c